<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<link href="../static/bootstrap/css/bootstrap.css" rel="stylesheet" />
	<link href="../static/css/orderList.css" rel="stylesheet" />
	<body>
		<div class="order-container">
			<div class="order-head">
				<span>我的订单</span>
				<span style="float: right;"><a href="../index.html">返回首页</a></span>
			</div>
			<hr /><br />
		</div>
	</body>
	<script src="../static/js/jquery-3.0.0.min.js"></script>
	<script src="../static/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$.ajax({
				url:"/order/orderList",
				type:"post",
				headers: {
					Authorization: sessionStorage.Authorization
				},
				success:function(result){
					if(result.code==200){
						let list = result.data;
						for (let i=0 ; i<list.length;i++){
							let order =list[i];
							let listr =
								"<div class='order-desc'>"+
								"<div class='first-div'>"+
								"<span>订单号："+order.id+"</span>"+
								"<span class='to-right'>交易成功</span>"+
								"</div>"+
								"<div class='second-div'>"+
								"<div class='img-div'>"+
								"<img src='"+order.image+"' />"+
								"</div>"+
								"<div class='span-div'>"+
								"<span>商品名："+order.name+"</span>"+
								"<span class='to-right'>支付金额：¥"+order.amount+"</span>"+
								"</div>"+
								"<div class='span-div'>"+
								"<span>收货地址："+order.address+"</span>"+
								"</div>"+
								"<div class='span-div'>"+
								"<span>备注："+order.remarks+"</span>"+
								"</div>"+
								"</div>"+
								"</div>";
							$(".order-head").append(listr);
						}
					}else if(result.code==401){
						sessionStorage.removeItem("Authorization");
						layer.msg(result.msg,{icon: 2,time:2000},function(){window.location.href="../index.html"});
					}else{
						layer.msg(result.msg,{icon: 2,time:2000});
					}
				}
			});
		});
	</script>
</html>
